import java.util.Stack;

public class TreeNode{

    int val;
    TreeNode right;
    TreeNode left;

    TreeNode() {}
      TreeNode(int val) { this.val = val; }
     TreeNode(int val, TreeNode left, TreeNode right) {
         this.val = val;
         this.left = left;
         this.right = right;
     }
}


class Solution {
    public boolean isBalanced(TreeNode root) {
        if(root == null){
            return true;
        }else {
            return Math.abs(height(root.left) - height(root.right)) <= 1 && isBalanced(root.left)
            && isBalanced(root.right);
        }
    }

    public int height(TreeNode root){
        if(root == null){
            return 0;
        }else{
            return Math.max(height(root.left),height(root.right)) + 1;
        }
    }



    public boolean isValid (String s) {
        // write code here

        Stack<Character>  Valid =  new Stack<>();

        for (int i = 0; i < s.length(); i++) {
            char S = s.charAt(i);
            Valid.add(S);

        }
    }
}




}